home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / HDX_BACK / HDX302.TT / PART.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-09  |  2.6 KB  |  163 lines

  1. /* part.c */
  2.  
  3.  
  4. /*
  5.  * 24-Nov-88    jye.     change and add codes so that can be used for MS-DOS
  6.  */
  7. #include "obdefs.h"
  8. #include "gemdefs.h"
  9. #include "osbind.h"
  10. #include "defs.h"
  11. #include "part.h"
  12. #include "bsl.h"
  13. #include "hdx.h"
  14. #include "addr.h"
  15.  
  16.  
  17. extern char sbuf[];
  18. extern int rebootp;
  19. extern int npart;
  20. extern int uplim;
  21. extern long bslsiz;
  22. extern long gbslsiz();
  23.  
  24. /*
  25.  * Complain about partition error.
  26.  *
  27.  */
  28. parterr(devno)
  29. int devno;
  30. {
  31.     char *pdev="X";
  32.     
  33.     *pdev = devno + '0';
  34.     (cantpart[PTNDEV].ob_spec)->te_ptext = pdev;
  35.     cantpart[PTNERROK].ob_state = NORMAL;
  36.     execform(cantpart);
  37.     return ERROR;
  38. }
  39.  
  40.  
  41. /*
  42.  * Fill in partition entry with default information
  43.  * and configuration values from the current "pr" wincap entry.
  44.  *
  45.  */
  46. fillpart(n, part)
  47. int n;
  48. PART *part;
  49. {
  50.     long num;
  51.     char *partid;
  52.     char *idstr = "XX";
  53.     char *wgetstr();
  54.  
  55.     idstr[1] = n + '0';
  56.  
  57.     /* see if `pX' is mentioned */
  58.     *idstr = 'p';
  59.     if (wgetnum(idstr, &num) == OK)
  60.     {
  61.     /* do the ST partition assignment */
  62.         npart++;
  63.         part->p_siz = (LONG)(num / 512);
  64.            part->p_flg = P_EXISTS;
  65.         if (part->p_siz < MB16)    {
  66.             part->p_id[0] = 'G';
  67.             part->p_id[1] = 'E';
  68.             part->p_id[2] = 'M';
  69.         } else {
  70.             part->p_id[0] = 'B';
  71.             part->p_id[1] = 'G';
  72.             part->p_id[2] = 'M';
  73.         }
  74.     }
  75. }
  76.  
  77.  
  78.  
  79. /*
  80.  * Force checksum of sector image to a value
  81.  */
  82. forcesum(image, sum)
  83. UWORD *image;
  84. UWORD sum;
  85. {
  86.     register int i;
  87.     register UWORD w;
  88.  
  89.     w = 0;
  90.     /* up limit is half of buffer size - 2 */
  91.     for (i = 0; i < ((UWORD)BPS/2 - 1); ++i)
  92.     w += *image++;
  93.     *image++ = sum - w;
  94. }
  95.  
  96.  
  97. /*
  98.  * Put word in memory in 8086 byte-reversed format.
  99.  *
  100.  */
  101. iw(wp, w)
  102. UWORD *wp;
  103. UWORD w;
  104. {
  105.     char *p;
  106.  
  107.     p = (char *)wp;
  108.     p[0] = (w & 0xff);
  109.     p[1] = ((w >> 8) & 0xff);
  110. }
  111.  
  112. /*
  113.  * Put long word in memory in 8086 word-reversed format.
  114.  *
  115.  */
  116. ilong(lp, l)
  117. long *lp;
  118. long l;
  119. {
  120.     UWORD *p;
  121.  
  122.     p = (UWORD *)lp;
  123.     iw(&p[0],(UWORD)(l & 0xffff));
  124.     iw(&p[1],(UWORD)((l >> 16) & 0xffff));
  125. }
  126.  
  127. /*
  128.  * Get long word in memory, from 8086 word-reversed format.
  129.  *
  130.  */
  131. glong(al, lp)   /* al is a swaped return long word,*/
  132.                 /* lp is a to be swaped long word */
  133. long *al;
  134. long *lp;
  135.  
  136. {
  137.    char *p, *q;
  138.  
  139.     p = (char *)al;
  140.     q = (char *)lp;
  141.     p[0] = q[3];
  142.     p[1] = q[2];
  143.     p[2] = q[1];
  144.     p[3] = q[0];
  145. }
  146.  
  147. /*
  148.  * Get word in memory, from 8086 byte-reversed format.
  149.  *
  150.  */
  151. UWORD gw(wp, aw)
  152. UWORD *wp;
  153. UWORD *aw;
  154. {
  155.     char *p, *q;
  156.  
  157.     p = (char *)wp;
  158.     q = (char *)aw;
  159.     q[0] = p[1];
  160.     q[1] = p[0];
  161.     return *aw;
  162. }
  163.